﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MES_SystemUI.Domain
{
    /// <summary>
    /// 设备登记表
    /// </summary>
    public class Device
    {
        /// <summary>
        /// 设备主键，自动编号
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int DeviceId { get; set; }
        /// <summary>
        /// 设备编码，不能重复
        /// </summary>
        [Required]
        [Column(TypeName ="varchar")]
        [StringLength(20)]
        //[Index(IsUnique =true)]
        public string DeviceCode { get; set; }
        /// <summary>
        /// 设备名称，不能重复
        /// </summary>
        [Required]
        [Column(TypeName ="varchar")]
        [StringLength(30)]
        [Index (IsUnique =true)]
        public string DeviceName { get; set; }
        /// <summary>
        /// 设备类型，外键
        /// </summary>
        [Required]
        public int DeviceCategoryId { get; set; }
        /// <summary>
        /// 设备规格，外键
        /// </summary>
        [Required]
        public int DeviceSpecId { get; set; }
        /// <summary>
        /// 单位。外键
        /// </summary>
        [Required]
        public int DeviceUnitId { get; set; }
        /// <summary>
        /// 设备状态（0在库中，1使用中，2维护中，3其他），默认值0
        /// </summary>
        [Required]
        public int DeviceStatus { get; set; }
        /// <summary>
        /// 登录人，外键
        /// </summary>
        [Required]
        public int RegisterId { get; set; }
        /// <summary>
        /// 登录日期
        /// </summary>
        [Required]
        public DateTime RegisterTime { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [Column(TypeName ="varchar")]
        [StringLength(150)]
        public string Remark { get; set; }
        /// <summary>
        /// 数据状态（0正常，1删除）默认值0
        /// </summary>
        [Required]
        public int Status { get; set; } = 0;
        /// <summary>
        /// 创建人，外键
        /// </summary>
        [Required]
        public int CreateUserId { get; set; }
        /// <summary>
        /// 创建时间，默认值当前时间
        /// </summary>
        [Required]
        public DateTime CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 最后一次修改人，外键
        /// </summary>
        public int? LastUpdateUserId { get; set; }
        /// <summary>
        /// 最后一次修改时间
        /// </summary>
        public DateTime? LastUpdateTime { get; set; }
    }
}
